package com.jt.common.util;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduledExecuteService {
    public static void main(String[] args) {
        //构建一个线程池对象
        ScheduledExecutorService service =
                Executors.newScheduledThreadPool(5);
        //任务对象
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                String name = Thread.currentThread().getName();
                System.out.println(name + "->" + System.currentTimeMillis());
            }
        };
        //定时执行任务 初始延迟 间隔执行 时间单位秒
        service.scheduleAtFixedRate(runnable, 1, 1, TimeUnit.MINUTES);
    }
}
